﻿using System.Drawing;
using System.Windows.Forms;

namespace RPG1
{
    class Necromancer : Role
    {
        private PictureBox wpnPicBox;
        public PictureBox WpnPicBox { get => wpnPicBox; set => wpnPicBox = value; }
        public Necromancer(string name, int originalLife, int currentLife, int damage, int agile, int brains, int speed,
            PictureBox picBox, Label bottomLabel, Label topLabel, Weapon wpn, PictureBox wpnPicBox)
            : base(name, originalLife, currentLife, damage, agile, brains, speed, picBox, bottomLabel, topLabel, wpn)
        {
            // 继承自父类的属性
            Name = name;
            OriginalLife = originalLife;
            CurrentLife = currentLife;
            Damage = damage;
            Agile = agile;
            Brains = brains;
            Speed = speed;
            PicBox = picBox;
            BottomLabel = bottomLabel;
            TopLabel = topLabel;
            Wpn = wpn;
            WpnPicBox = wpnPicBox;
        }
        public override int getAttack()
        {
            return (int)(Damage * 2 + Brains * 4 + Wpn.Atk);
        } //魔法师攻击力=力量*2+智力*4+武器的攻击力
        public override int getDefense()
        {
            return (int)(Agile * 3.6 + Damage * 1.5 + Brains * 2 + Wpn.Defense);
        } //魔法师防御力=敏捷*3.6+力量*1.5+智力*2+武器的防御力
        public void goBack()
        {
            Delay(40000);
            //返回，当前位置=原始位置
            wpnPicBox.Location = new Point(PicBox.Location.X+PicBox.Width/2, PicBox.Location.Y-wpnPicBox.Height-15);
        }
        public override void attack(Role role)
        {
            // 移动到怪兽面前
            int diffX = role.PicBox.Location.X + role.PicBox.Width
                - wpnPicBox.Location.X;
            int diffY = role.PicBox.Location.Y - wpnPicBox.Location.Y - 10;

            for (int i = 1; i <= 10; i++)
            {
                wpnPicBox.Location = new Point(wpnPicBox.Location.X + diffX / 10,
                   wpnPicBox.Location.Y + diffY / 10);
                Delay(20000);
            }
            role.bloodLoss(this.getAttack() - role.getDefense());
            goBack();
            WpnPicBox.BringToFront();
        }
    }
}
